#include <interface\styleSheet.h>
#include <cstdio>

styleSheet::styleSheet():ressource(){
    RSname = "<STYLESHEET>";
    setColor(STATUS(bkg_st_normal),new color(col_black));
    setColor(STATUS(txt_st_normal),new color(col_black));
}
styleSheet::~styleSheet(){
    printf("Stylesheet deletion\n");
    for( map<colorCode_t,color*>::iterator i = colors.begin(); i != colors.end(); i++ ){
        delete i->second;
    }
}

void styleSheet::setColor(colorCode_t type,color* col){
    map<colorCode_t,color*>::iterator i;
    if( (i = colors.find(type)) != colors.end() ){
        delete (i->second);
        i->second = col;
    }else{
        colors.insert( pair<colorCode_t,color*>(type,col) );
    }
}
color* styleSheet::getColor(colorCode_t type){
    map<colorCode_t,color*>::iterator i;
    if( (i = colors.find(type)) != colors.end() ){
        return i->second;
    }
    return NULL;
}
